<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>10key和数组检测</title>
    <style>
        .redBorder{
            border-color: red;
            border-width: 1px;
            border-style: solid;
        }
    </style>
</head>
<body>
<div id="app">
    计算器：{{ counter }}<br>
    <ul>
        <!--绑定key之后，添加元素时会保留checkbox的状态-->
        <li v-for="(item, index) in array" v-bind:key="item.city"><input type="checkbox"/>{{index}}: {{item.city}}</li>
    </ul>
    <ul>
        <li v-for="(value, key, index) in object">{{index}}-{{key}}: {{value}}</li>
    </ul>
    <button v-on:click="add()">添加</button>
</div>
<script src="../vue.global.3.0.5.js"></script>
<script>
    //声明一个选项对象
    const App={
        //初始数据
        data() {
            return {
                counter: 100,
                //vm.array.push({city:"深圳"});//在数组尾部添加元素
                //vm.array[1]={city:"南京"}
                //push()/pop()/unshift()/shift()/splice()/sort()/reverse()会修改原对象，且修改后立马渲染视图
                array: [{city:"北京"}, {city:"上海"}, {city:"广州"}],
                object: {name:"蝈蝈", age:12, gender:"男"}
            }
        },
        methods: {
            add() {
                this.array.unshift({city:"深圳"});
            }
        },
        computed: {
            compClassName: {
                get() {
                    
                },
                set(value) {

                }
            }
        }
    }

    //全局API对象，创建应用对象返回(选项对象).挂载方法(DOM节点)
    const vm = Vue.createApp(App).mount("#app");
</script>
</body>
</html>